package com.goodfather.textbook.youdao.pad.weight;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.goodfather.textbook.youdao.pad.R;


public class WebRequestProgress extends OverlayView {
    private TextView tv_loading;

    public WebRequestProgress(Context context) {
        super(context);
        initView(context);
    }

    public WebRequestProgress(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    void initView(Context context){
        View view = LayoutInflater.from(context).inflate(R.layout.view_progress,this,true);
        tv_loading = view.findViewById(R.id.tv_loading);

    };

    public void showProgress(){
        showProgress(null);
    }

    public void showProgress(String loading){
        if (tv_loading != null){
            if (TextUtils.isEmpty(loading)){
                tv_loading.setVisibility(GONE);
            }else {
                tv_loading.setText(loading);
                tv_loading.setVisibility(VISIBLE);
            }
        }
        this.show();
    }
}
